<?php
	require_once('Connections/conexao.php'); 

	$id = $_GET['id'];
	
	mysql_select_db($database_conexao, $conexao);	
	$queryNot = "SELECT * FROM noticias WHERE id = '$id'";
	$Not = mysql_query($queryNot, $conexao) or die(mysql_error());
	$rowNot = mysql_fetch_assoc($Not);
	$totalRowsNot = mysql_num_rows($Not);
	
	mysql_select_db($database_conexao, $conexao);		
	$queryComm = "SELECT * FROM comentarios WHERE id_noticia = '$id'";
	$Comm = mysql_query($queryComm, $conexao) or die(mysql_error());
	$rowComm = mysql_fetch_assoc($Comm);
	$totalRowsComm = mysql_num_rows($Comm);
	
	mysql_select_db($database_conexao, $conexao);		
	$queryImg = "SELECT imagem FROM usuarios WHERE id = '".$_SESSION["id"]."'";
	$Img = mysql_query($queryImg, $conexao) or die(mysql_error());
	$rowImg = mysql_fetch_assoc($Img);
	$totalRowsImg = mysql_num_rows($Img);
?>

<div id="nt-safe">

	<div id="nt-superior">
	    <h2><?php echo $rowNot['titulo']; ?></h2>
    
    	<div id="nt-superior-txt">
			<?php echo $rowNot['texto']; ?>
        </div>
    </div>
    
    <div id="nt-opcoes">
    	<div id="nt-opcoes-meio">
        <?php if (isset($_SESSION["autenticado"]) == true) { ?>
    	<div id="nt-opcoes1" class="nt-opcoes"><a href="?pg=noticia&id=<?php echo $rowNot['id']; ?>#nt-opcoes">O que eu acho</a></div>
        <?php } else { ?>
        <div id="nt-opcoes1" class="nt-opcoes"><a href="?pg=login">O que eu acho</a></div>
        <?php } ?>
        <div id="nt-opcoes2" class="nt-opcoes">Ler mais tarde</div>
        <div id="nt-opcoes3" class="nt-opcoes">Falar pra todo mundo</div>
        </div>
    </div>
    
    <div id="nt-comentarios">
    	<h2>Comentários</h2>

		<?php if (isset($_SESSION["autenticado"]) == true) { ?>
		<div id="nt-coment-safe">
        	<div id="nt-coment-box">
            	<form name="enviarComentario" method="post" action="files/lib/php/comentario-enviar.php" >
                    <input type="hidden" name="usuario" value="<?php echo $_SESSION['nome']; ?>" />
                    <input type="hidden" name="id_noticia" value="<?php echo $_GET['id']; ?>" />                
                    <div id="coment-box-foto"><img src="files/images/users/<?php echo $rowImg['imagem']; ?>" width="70" height="80" /></div>
                    <div id="coment-box-nome"><?php echo $_SESSION['nome']; ?><span></span></div>
                    <div id="coment-box-txt"><textarea id="coment-box-texto" name="comentario" required></textarea></div>
                    <div id="coment-box-botoes">
                        <div><input id="box-bt-ok" type="submit" name="enviar" value="" title="Enviar Comentário" class="box-bt" /></div>
                        <div><input id="box-bt-cancel" type="reset" name="limpar" value="" title="Cancelar" class="box-bt" /></div>
                    </div>
                </form>

            </div>
        </div>
        <?php } ?>
        
        <div id="nt-coment-safe">
        	<div id="nt-coment-box">
            	
                <div id="coment-box-foto"><img src="files/images/users/<?php echo $rowImg['imagem']; ?>" width="70" height="80" /></div>
                <div id="coment-box-nome"><?php echo $rowComm['nome_usuario']; ?><span> - 2 horas atrás</span></div>
                <div id="coment-box-texto1"><?php echo $rowComm['texto']; ?></div>

            </div>
        </div>
        
               
        
    
    </div>

</div>